package uml.objects;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Shape;
import java.awt.TextField;
import java.awt.geom.AffineTransform;

import uml.util.UMLConstants;

/**
 * @author Rick Myers
 */
public class ArrowEnd
{
	private Shape m_shape;
	private AffineTransform m_transform;
	private Color m_color;
	
	/**
	 * contructs an arrow end of shave s and color c
	 * @param c
	 * @param s
	 */
	
	public ArrowEnd(Color c, Shape s)
	{
		m_shape = s;
		m_color = c;
		m_transform = new AffineTransform();
	}
	
	/**
	 * paints the arrowend at the angle of the line from point 1 to pioint 2
	 * @param g
	 * @param x1
	 * @param y1
	 * @param x2
	 * @param y2
	 */
	
	public void paint(Graphics2D g, int x1, int y1, int x2, int y2)
	{
		AffineTransform oldTransform = g.getTransform();
		m_transform.setToRotation (x2-x1, y2 - y1, x2, y2);
		m_transform.translate (x2, y2);
		g.transform(m_transform);
		g.setColor (m_color);
		g.fill(m_shape);
		g.setColor(UMLConstants.ARROW_END_BORDER_COLOR);
		g.draw(m_shape);
		g.setTransform(oldTransform);
	}
}